import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import nodeResolve from "@rollup/plugin-node-resolve";
import clear from "rollup-plugin-clear";
import typescript from "rollup-plugin-typescript2";

export default {
  input: "src/index.ts",
  output: {
    file: "dist/index.js",
    format: "esm",
  },
  treeshake: false,
  onwarn: (msg, warn) => {
    if (msg.code !== "CIRCULAR_DEPENDENCY") {
      warn(msg);
    }
  },
  plugins: [
    json(),
    nodeResolve({
      extensions: [".js", "jsx", ".ts", "tsx"],
    }),
    commonjs(),
    typescript(),
    // htmlTemplate({
    //   template: "public/index.html",
    //   target: "dist/index.html",
    //   attrs: ['type="module"'],
    // }),
    clear({ targets: ["dist"] }),
  ],
};
